package ink.ykb.demo.permission.dao;
import java.util.List;

import org.beetl.sql.core.annotatoin.Sql;
import org.beetl.sql.core.mapper.BaseMapper;

import ink.ykb.demo.permission.entity.Role;

public interface RoleDao extends BaseMapper<Role> {

  /**
   * 根据id获取角色
   * @param id
   * @return
   */
  @Sql("select * from role where id = ?")
  Role getRoleById(Long id);

  /**
   * 根据code获取角色
   * @param code
   * @return
   */
  @Sql("select * from role where code = ?")
  Role getRoleByCode(String code);
  
  /**
   * 根据code获取角色(加锁)
   * @param code
   * @return
   */
  @Sql("select * from role where code = ? for update")
  Role getRoleAndLock(String code);

  /**
   * 查询所有角色
   * @return
   */
  @Sql("select * from role")
  List<Role> getRoleList();
}